<template>
    <div id="parts">
        <el-table :data="dataList" stripe border class="table-index" :height="tableHeight" style="width: 100%;" :header-cell-style="getRowClass" v-loading="loading">
            <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
            <el-table-column prop="jqylMaterialdetail.nameName" label="物料名称" sortable min-width="160"></el-table-column>
            <el-table-column prop="jqylMaterialdetail.pcode" label="物料条码" sortable min-width="160"></el-table-column>
            <el-table-column prop="jqylMaterialdetail.batchnums" label="物料批号" sortable min-width="130"></el-table-column>
            <el-table-column prop="jqylMaterialdetail.typenums" label="物料型号" sortable min-width="110"></el-table-column>
            <el-table-column prop="jqylMaterialdetail.remark" label="备注" sortable min-width="110"></el-table-column>
            <el-table-column prop="result" label="供应商补货" sortable  width="120">
                <template slot-scope="scope">
                    <span :class="scope.row.result===1?'el-icon-circle-check cl-success':'el-icon-circle-close cl-danger'" class="icon-circle"></span>
                </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                <template slot-scope="scope">
                    <el-button @click="updateList(scope.row)" type="text" size="small">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"></el-pagination>
        <!-- 详情信息 -->
        <el-dialog :title="dialog1.title" width="800" top="30px" :visible.sync="dialog1.isShow" :close-on-click-modal="false" >
            <el-form :inline="true" class="demo-form-inline" v-model="dialog1.formData" label-position="right" label-width="180px" v-if="dialog1.formData.jqylMaterialdetail">
                <el-form-item label="物料名称" >
                    <el-input  v-model="dialog1.formData.jqylMaterialdetail.nameName" disabled></el-input>
                </el-form-item>
                <el-form-item label="物料条码" >
                    <el-input  v-model="dialog1.formData.jqylMaterialdetail.pcode" disabled></el-input>
                </el-form-item>
                <el-form-item label="物料批号" >
                    <el-input  v-model="dialog1.formData.jqylMaterialdetail.batchnums" disabled></el-input>
                </el-form-item>
                <el-form-item label="物料型号" >
                    <el-input  v-model="dialog1.formData.jqylMaterialdetail.typenums" disabled></el-input>
                </el-form-item>
                <el-form-item label="供应商是否补货" >
                     <el-select v-model="dialog1.formData.result">
                        <el-option label="否" :value="0"></el-option>
                        <el-option label="是" :value="1"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align: center;">
                <el-button @click="updateRecord" type="primary">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import scybHttp from '@/axios/scybHttp.js'

    export default {
        name: "",
        components:{
        },
        data() {
            let token = sessionStorage.getItem("tokenId");
            let menuId = sessionStorage.getItem('menuId');
            return {
                tokenId: token,
                menuId:menuId,
                pagination:{
                    currentPage:1,
                    pageSize:10,
                    total:0
                },
                tableHeight: document.documentElement.clientHeight - 135,
                dataList: [],
                loading:false,
                dialogHeightPane: {
                    height: (document.documentElement.clientHeight - 180) + 'px',
                    overflowY: 'auto'
                },
                dialogTableHeight: document.documentElement.clientHeight - 260,
                dialog1:{
                    isShow:false,
                    title:'',
                    formData:{}
                }

            };
        },
        created() {
            let self = this;
            self.getTableList();
        },
        methods: {
            getTableList(){
                let self = this;
                let postData={
                    currentPage:self.pagination.currentPage,
                    pageSize:self.pagination.pageSize
                }
                switch(self.menuId){
                    case "5193":
                        postData.state=0
                        break;
                    case "5194":
                        postData.state=1;
                        break;
                }
                self.loading= true;
                scybHttp.returnSupplierList(postData).then(res=>{
                    self.loading= false;
                    self.dataList = res.content.records;
                    self.pagination.total =res.content.total;
                },error=>{
                    self.loading= false;
                })
            },
            handleSizeChange(size){
                this.pagination.size = size;
                this.getTableList();
            },
            handleCurrentChange(current){
                this.pagination.currentPage = current;
                this.getTableList();
            },
            updateList(row){
                let self = this;
                self.dialog1.title="编辑";
                self.dialog1.isShow= true;
                self.dialog1.formData=row;
            },
            updateRecord(){
                let self = this;
                scybHttp.updateReturnSupplier(self.dialog1.formData).then(res=>{
                    self.getTableList();
                    self.dialog1.isShow= false;
                    self.$message.success("修改成功")
                })
            }
        }
    }
</script>

<style scoped>
</style>
